package com.teacold.tfactivity;

import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;

import com.teacold.customdemo.R;
import com.teacold.customdemo.customview.ItemLongClickMaskHelper;
import com.teacold.customdemo.customview.TFZHLayout;
import com.teacold.customdemo.customview.TouchCallbackRecyclerView;
import com.teacold.utils.toast.ToastTool;

import java.util.ArrayList;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

public class SwitchAccount extends AppCompatActivity implements TouchCallbackRecyclerView.ScrollCallback, TFZHLayout.TFLongClickListener, SwitchAdapter.ItemClickCallback {
   private TouchCallbackRecyclerView switch_recycler;
   private ArrayList<String> mData=new ArrayList<>();
    private SwitchAdapter adapter;
    private ItemLongClickMaskHelper maskHelper;
    private int mItemLongClickPosition;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tf_switchaccount_layout);
      initView();
    }

    private void initView() {
        switch_recycler=findViewById(R.id.switch_recycler);
        for (int i = 0; i <5 ; i++) {
            mData.add("闪光少女"+i+"好");
        }
        switch_recycler.setLayoutManager(new GridLayoutManager(this,2));
        adapter=new SwitchAdapter(mData,this);
        maskHelper=new ItemLongClickMaskHelper(this);
        maskHelper.setMaskItemListener(this);
        adapter.setmItemClickCallback(this);


        switch_recycler.setScrollCallback(this);
        switch_recycler.setAdapter(adapter);



    }


    @Override
    public void onTouchUp(float diffY) {
        maskHelper.dismissItemMaskLayout();

    }

    @Override
    public void deleteZH() {

    }

    @Override
    public void itemClick(View view, int position) {
        maskHelper.dismissItemMaskLayout();
        ToastTool.ToastTool(this,"点击添加！");


    }

    @Override
    public void itemLongClick(View view, int position) {
        mItemLongClickPosition = position;
        maskHelper.setRootFrameLayout((FrameLayout)view);
    }
}
